package com.itheima.case1;

public class case1Thread extends Thread{
    static int ticket = 1000;
    @Override
    public void run() {
        while(true){
            synchronized (case1Thread.class){
                try {
                    Thread.sleep(3);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                if(ticket > 0){
                    ticket --;
                    System.out.println(getName()+"售出第"+(1000-ticket)+"张票");
                }else{
                    break;
                }
            }
        }
    }
}
